<?php

namespace App\Models;

use App\Http\Helper\UrlSchemaHelper;
use App\Http\Helper\YunXinServerAPI;
use App\Models\Concerns\CommentTraits;
use App\Http\Controllers\Weixin\WechatTemplateController;

/**
 * Class Product
 * @property integer id
 * @property integer user_id
 * @property float price 价格
 * @property integer status 商品状态
 * @property string address 想去的地方
 * @property string act 行为(干什么)
 * @property string voice 语音介绍
 * @property integer voice_type 语音链接类型，1：微信，2：url
 * @property string type 商品类型
 * @property integer voice_length
 * @property date server_time
 * @property string server_day
 * @property string server_unit
 * @property integer channel
 * @property boolean allow_repeat 是否允许重复下单
 * @property boolean is_report 是否被举报
 * @property boolean is_down 语音是否被下载
 * @property integer skill_id 技能ID
 * @property integer sort 排序
 * @property integer skill_tag_id 技能标签ID
 * @property float level 星级评分
 * @property User user
 * @property Skill skill
 * @property SkillTag skillTag
 * @property Purchase purchases
 *
 */
class ProductRecord extends ApplicationModel
{
    use CommentTraits;

    protected $fillable = [
        'user_id',
        'price',
        'status',
        'address',
        'act',
        'voice',
        'server_time',
        'channel',
        'type',
        'voice_type',
        'voice_length',
        'allow_repeat',
        'skill_id',
        'level',
        'sort',
        'server_day',
        'is_report',
        'server_unit',
        'skill_tag_id',
        'tag_id',
        'tag_title',
        'location_status',
        'update_type',
        'update_service_flag',
        'update_picture_flag',
        'update_act_flag'
    ];

    const STATUS_AUDITING = 1;//审核中
    const STATUS_RELEASE = 2;//已发布
    const STATUS_REJECT = 3;//拒绝中
    const STATUS_OFF = 4;//已接订单下架
    const STATUS_UPDATE_AUDING = 5; //修改审核中
    const STATUS_UPDATE_RELEASE = 6; //修改审核通过
    const STATUS_UPDATE_REJECT = 7; //修改审核拒绝

    public function product()
    {
        return $this->belongsTo(Product::class);
    }

    public function pictures()
    {
        return $this->hasMany(ProductRecordPicture::class,'product_record_id')->where('type','Product');
    }



}
